package com.ruoyi.web.controller.check;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.check.domain.ECheckListFormYichang;
import com.ruoyi.check.service.IECheckListFormYichangService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 异常信息Controller
 *
 * @author hugh.sun
 * @date 2023-05-30
 */
@RestController
@RequestMapping("/check/yichang")
public class ECheckListFormYichangController extends BaseController
{
    @Autowired
    private IECheckListFormYichangService eCheckListFormYichangService;

    /**
     * 查询异常信息列表
     */
    @PreAuthorize("@ss.hasPermi('check:yichang:list')")
    @GetMapping("/list")
    public TableDataInfo list(ECheckListFormYichang eCheckListFormYichang)
    {
        startPage();
        List<ECheckListFormYichang> list = eCheckListFormYichangService.selectECheckListFormYichangList(eCheckListFormYichang);
        return getDataTable(list);
    }

    @GetMapping("/list1")
    public TableDataInfo list1()
    {
        ECheckListFormYichang eCheckListFormYichang1 = new ECheckListFormYichang();
        List<ECheckListFormYichang> list = eCheckListFormYichangService.selectECheckListFormYichangList(eCheckListFormYichang1);
        return getDataTable(list);
    }

    /**
     * 导出异常信息列表
     */
    @PreAuthorize("@ss.hasPermi('check:yichang:export')")
    @Log(title = "异常信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ECheckListFormYichang eCheckListFormYichang)
    {
        List<ECheckListFormYichang> list = eCheckListFormYichangService.selectECheckListFormYichangList(eCheckListFormYichang);
        ExcelUtil<ECheckListFormYichang> util = new ExcelUtil<ECheckListFormYichang>(ECheckListFormYichang.class);
        util.exportExcel(response, list, "异常信息数据");
    }

    /**
     * 获取异常信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:yichang:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eCheckListFormYichangService.selectECheckListFormYichangById(id));
    }

    /**
     * 新增异常信息
     */
    @PreAuthorize("@ss.hasPermi('check:yichang:add')")
    @Log(title = "异常信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ECheckListFormYichang eCheckListFormYichang)
    {
        return toAjax(eCheckListFormYichangService.insertECheckListFormYichang(eCheckListFormYichang));
    }

    /**
     * 修改异常信息
     */
    @PreAuthorize("@ss.hasPermi('check:yichang:edit')")
    @Log(title = "异常信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ECheckListFormYichang eCheckListFormYichang)
    {
        return toAjax(eCheckListFormYichangService.updateECheckListFormYichang(eCheckListFormYichang));
    }

    /**
     * 删除异常信息
     */
    @PreAuthorize("@ss.hasPermi('check:yichang:remove')")
    @Log(title = "异常信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eCheckListFormYichangService.deleteECheckListFormYichangByIds(ids));
    }
}
